﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fated.Character.ChartGeneration {
    /// <summary>
    /// Completed: Checks for Mars,Moon,Venus,Mercury
    /// Needs:Jupiter/Saturn
    /// </summary>
    class Sun : Planet{
        private static int capacity = 10;
       
        private static int toMars = 0;
        private static int toMoon = 0;
        private static int toVenus = 0;
        private static int toMercury = 0;
        public static void clear() {
            toMars = 0;
            toMoon = 0;
            toMercury = 0;
            toVenus = 0;
            capacity = 10;
        }
        public static void addAspect(PlanetNames p, Aspect.AspectType a) {
            if (p == PlanetNames.Mars) {
                if (a == Aspect.AspectType.Trine) toMars = vLargeUp;
                if (a == Aspect.AspectType.Sextile) toMars = largeUp;
                if (a == Aspect.AspectType.Conjunct) toMars = xLargeUp;
                if (a == Aspect.AspectType.Square) toMars = smallDown;
                if (a == Aspect.AspectType.Opposite) toMars = largeDown;
            } else if (p == PlanetNames.Moon) {
                if (a == Aspect.AspectType.Trine) toMoon = vLargeUp;
                if (a == Aspect.AspectType.Sextile) toMoon = largeUp;
                if (a == Aspect.AspectType.Conjunct) toMoon = xLargeUp;
                if (a == Aspect.AspectType.Square) toMoon = smallDown;
                if (a == Aspect.AspectType.Opposite) toMoon = largeDown;
            } else if (p == PlanetNames.Venus) {
                if (a == Aspect.AspectType.Trine) toVenus = vLargeUp;
                if (a == Aspect.AspectType.Sextile) toVenus = largeUp;
                if (a == Aspect.AspectType.Conjunct) toVenus = xLargeUp;
                if (a == Aspect.AspectType.Square) toVenus = smallDown;
                if (a == Aspect.AspectType.Opposite) toVenus = largeDown;
            } else if (p == PlanetNames.Mercury) {
                if (a == Aspect.AspectType.Trine) toMercury = vLargeUp;
                if (a == Aspect.AspectType.Sextile) toMercury = largeUp;
                if (a == Aspect.AspectType.Conjunct) toMercury = xLargeUp;
                if (a == Aspect.AspectType.Square) toMercury = smallDown;
                if (a == Aspect.AspectType.Opposite) toMercury = largeDown;
            } else if (p == PlanetNames.Jupiter) {
                if (a == Aspect.AspectType.Trine) capacity += largeUp;
                if (a == Aspect.AspectType.Sextile) capacity += smallUp;
                if (a == Aspect.AspectType.Conjunct) capacity += vLargeUp;
                if (a == Aspect.AspectType.Square) capacity += smallDown;
                if (a == Aspect.AspectType.Opposite) capacity += largeDown;
            } else if (p == PlanetNames.Saturn) {
                if (a == Aspect.AspectType.Trine) capacity += largeUp;
                if (a == Aspect.AspectType.Sextile) capacity += smallUp;
                if (a == Aspect.AspectType.Conjunct) capacity += largeDown;
                if (a == Aspect.AspectType.Square) capacity += smallDown;
            }
        }
        public static void getStats(out float[] amount, out int[] affected) {
            List<float> floatout = new List<float>();
            List<int> statout = new List<int>();

            if (toMercury > 0 && capacity > 0) {
                capacity -= toMercury;
                if (capacity < 0) toMercury += capacity;
                statout.Add((int)Chart.Stats.Mind);
                floatout.Add(toMercury);
            }
            if (toMoon > 0 && capacity > 0) {
                capacity -= toMoon;
                if (capacity < 0) toMoon += capacity;
                statout.Add((int)Chart.Stats.Spirit);
                floatout.Add(toMoon);
            }
            if (toVenus > 0 && capacity > 0) {
                capacity -= toVenus;
                if (capacity < 0) toVenus += capacity;
                statout.Add((int)Chart.Stats.Social);
                floatout.Add(toVenus);
            }
            if (toMars > 0 && capacity > 0) {
                capacity -= toMars;
                if (capacity < 0) toMars += capacity;
                statout.Add((int)Chart.Stats.Body);
                floatout.Add(toMars);
            }

            if (toVenus <= 0 && capacity < 0) {
                capacity -= toVenus;
                if (capacity > 0) toVenus += capacity;
                statout.Add((int)Chart.Stats.Social);
                floatout.Add(toVenus);
            }
            if (toMars <= 0 && capacity < 0) {
                capacity -= toMars;
                if (capacity > 0) toMars += capacity;
                statout.Add((int)Chart.Stats.Body);
                floatout.Add(toMars);
            }
            if (toMercury <= 0 && capacity < 0) {
                capacity -= toMercury;
                if (capacity > 0) toMercury += capacity;
                statout.Add((int)Chart.Stats.Mind);
                floatout.Add(toMercury);
            }
            if (toMoon <= 0 && capacity < 0) {
                capacity -= toMoon;
                if (capacity > 0) toMoon += capacity;
                statout.Add((int)Chart.Stats.Spirit);
                floatout.Add(toMoon);
            }
            
            amount = floatout.ToArray();
            affected = statout.ToArray();
        }
    }
}
